package com.k2data.k2app.domain.po;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.k2data.k2app.domain.po.v1.Contacts;
import com.k2data.k2app.domain.po.v1.Event;
import lombok.Data;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Map;

/**
 * @author lidong9144@163.com 17-3-20.
 */
@Data
@Table(name = "customer")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Customer implements Serializable {

    @Transient
    private static final long serialVersionUID = -6391479954207673460L;

    @JsonIgnore
    @Id
    @GeneratedValue(generator = "JDBC")
    private Long id;

    /**
     *  @NotNull
     *  @Pattern(regexp = "^[a-zA-Z][a-zA-Z0-9_]*$", message = "CustomerNo must be letter, number or underscode.")
     */
    private String customerNo;
    @NotNull
    private String name;
    private String type;
    private String industry;
    private Integer count;
    private Double longitude;
    private Double latitude;
    @JsonIgnore
    private Integer regionCode;
    @Transient
    @NotNull
    private String province;
    @Transient
    private String city;
    @Transient
    private String district;

    private String address;
    private Long roleId;
    private String contactPerson;
    @Pattern(regexp = "^[0-9]*$", message = "Tel must be number.")
    private String tel;
    @Pattern(regexp = "^[0-9]*$", message = "Mobile must be number..")
    private String mobile;
    private String imageUrl;
    @JsonIgnore
    private ZonedDateTime createTime;
    @JsonIgnore
    private ZonedDateTime updateTime;

    // 关联表
    @JsonIgnore
    @Transient
    private List<Device> devices;
    @JsonIgnore
    @Transient
    private List<EventFault> faults;
    @JsonIgnore
    @Transient
    private List<Event> faultsv2;

    @Transient
    private List fileList;
    @Transient
    private List<Contacts> contacts;
    @Transient
    private String editPermission;
    @Transient
    private String delPermission;
}
